<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
	<head>
		<title>用户管理</title>
		<base href="<%=basePath%>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<meta name="apple-mobile-web-app-title" content="Amaze UI" />
		<link rel="stylesheet" href="layui/css/layui.css" media="all"> <!-- 适应所有设备 -->
		<style type="text/css">
		</style>
	</head>
	<% String nowDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); %>
	<body>
		<div class="tpl-portlet-input tpl-fz-ml" style="float: left;">
			<!-- 通过form id来调用js里ajax,来实现参数的传递 -->
			<form class="layui-form" onsubmit='return false'>
				<!-- 返回所有玩家信息 -->
				<div class="layui-form-item">
					<div class="layui-input-inline">
						<input type="text" name="playerID" id="playerID" placeholder="玩家ID" autocomplete="off" class="layui-input">
					</div>
					
					<div class="layui-input-inline">
						<select name="Businessman" id="Businessman" lay-filter="Businessman">
						    <option value="0">全部</option>
						    <option value="1">普通玩家</option>
						    <option value="2">会长</option>
						</select>
					</div>
				
					<div class="layui-inline">
						<div class="layui-input-inline">
							<button class="layui-btn layui-btn-normal" data-type="reload" id="SelectOrder" lay-filter="SelectOrder">搜索</button>
						</div>
					</div>
				</div>
			</form>
		</div>
		</div>
		
		<table lay-filter="PlayerShow" id="PlayerShow" class="layui-table"/>
		
		<script type="text/html" id="barDemo">
<%--            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>--%>
            {{#  if(d.IsBlocked == 0){ }}
                 <a class="layui-btn layui-btn-xs" lay-event="edit">未锁定</a>
              {{#  } else { }}
                 <a class="layui-btn layui-btn-xs" lay-event="edit2">已锁定</a>
              {{#  } }}
        </script>

       <script type="text/html" id="RealGain">
            {{#  d.RealGain = d.TotalCurrencyWin - d.TotalCurrencyLost }}
                 <span>{{ d.RealGain }}</span>
            {{#  }}
       </script>

		<script src="js/jquery.min.js"></script>
		<script src="layui/layui.js"></script>
		<script src="js/personal/formsubmit.js"></script>
		<script src="js/common/monitor_back.js"></script>


			<script type="text/html" id="IsBusinessman">
            {{#  if(d.IsBusinessman === false){ }}
                <span class="layui-badge layui-bg-green">玩家</span>
            {{#  } else if(d.IsBusinessman === true){ }}
                <span class="layui-badge layui-bg-blue">会长</span>
            {{#  } }}
        </script>
        
        <script type="text/html" id="TotalRecharge">
            {{#  d.TotalRecharge = d.TotalRecharge/100 }}
                <span>{{ d.TotalRecharge }}</span>
            {{#  }}
        </script>
        
        <script type="text/html" id="PersonalInRecoverState">
            {{#  if(d.PersonalInRecoverState === false){ }}
                <span style="color:#1d953f">否</span>
            {{#  } else if(d.PersonalInRecoverState === true){ }}
                <span style="color:#ed1941">回血</span>
            {{#  } }}
        </script>
        
        <script type="text/html" id="StrongDifficultyLevel">
            {{#  if(d.StrongDifficultyLevel === 0){ }}
                <span class="layui-badge">极难</span>
            {{#  } else if(d.StrongDifficultyLevel === 1){ }}
                <span class="layui-badge">很难</span>
            {{#  } else if(d.StrongDifficultyLevel === 2){ }}
                <span class="layui-badge">难</span>
            {{#  } else if(d.StrongDifficultyLevel === 4){ }}
                <span class="layui-badge layui-bg-green">易</span>
            {{#  } else if(d.StrongDifficultyLevel === 5){ }}
                <span class="layui-badge layui-bg-green">很容易</span>
            {{#  } else if(d.StrongDifficultyLevel === 6){ }}
                <span class="layui-badge layui-bg-green">极易</span>
            {{#  } else if(d.StrongDifficultyLevel === -1){ }}
                <span class="layui-badge layui-bg-green">默认</span>
            {{#  } }}
        </script>
        <script type="text/html" id="PersonalDifficultyLevel">
            {{#  if(d.PersonalDifficultyLevel === 0){ }}
                <span style="color:#ed1941">极难</span>
            {{#  } else if(d.PersonalDifficultyLevel === 1){ }}
                <span style="color:#ef4136">很难</span>
            {{#  } else if(d.PersonalDifficultyLevel === 2){ }}
                <span style="color:#d93a49">难</span>
            {{#  } else if(d.PersonalDifficultyLevel === 4){ }}
                <span style="color:#00ae9d">易</span>
            {{#  } else if(d.PersonalDifficultyLevel === 5){ }}
                <span style="color:#45b97c">很容易</span>
            {{#  } else if(d.PersonalDifficultyLevel === 6){ }}
                <span style="color:#1d953f">极易</span>
            {{#  } else if(d.PersonalDifficultyLevel === -1){ }}
                <span>默认</span>
            {{#  } }}
        </script>
        
        <script type="text/html" id="PersonalMaxPrizePool">
            <span class="layui-badge layui-bg-green">{{ d.PersonalMaxPrizePool }}</span>
        </script>
        
        <script type="text/html" id="VipExp">
            <span class="layui-badge layui-bg-green">{{ d.VipExp }}</span>
        </script>
        
		<script type="text/javascript">

			layui.use(['form', 'layer', 'table'], function() {
			var form = layui.form;
			var layer = layui.layer;
			var table = layui.table;

				layer.config({
					extend: 'MySkin/style.css'
				});
				/* table.init('PlayerShow'); */
				
  var tableIns = table.render({
					elem:'#PlayerShow',
					url:'pa/list',
					method:'post',
					title:'玩家信息管理',
					autoSort: false,
					even:true,
					cellMinWidth:120,
					id:'AllTable',
					request:{
						pageName:'pageIndex',
						limitName:'pageCount'
					},
	  				page:{
						limit: 30,
						limits: [10, 20, 30, 40, 50],
					},
					where:{
						UserId : $('#playerID').val(),
						Businessman : $('#Businessman').val()
					},
					cols:[[
						{field:'Id',title:'ID',event:'ViewUserMessage',style: "color: #0000ff;"},
						{field:'Nickname',title:'昵称',hide:true},
						{field:'Level',title:'等级',sort:true},
						{field:'VipLevel',title:'VIP等级'},
						{field:'VipExp',title:'VIP经验',event:'VipExpChange',templet:'#VipExp'},
						{field:'Diamond',title:'钻石',hide:true},
						{field:'ItemLock',title:'锁定',hide:true},
						{field:'ItemFreeze',title:'冰冻',hide:true},
						{field:'ItemSummon',title:'召唤',hide:true},
						{field:'ItemWild',title:'狂暴',hide:true},
						{field:'ItemShadow',title:'分身',hide:true},
						{field:'Item10',title:'防水木料',hide:true},
						{field:'Item11',title:'精炼矿石',hide:true},
						{field:'Item12',title:'海妖外壳',hide:true},
						{field:'Item13',title:'潮汐精粹',hide:true},
						{field:'Item14',title:'深海魔晶',hide:true},
						{field:'ItemMultipleHit',title:'倍击',hide:true},
						{field:'Integral',title:'积分',hide:true},
						{field:'ItemTicket',title:'奖券',hide:true},
						{field:'ItemWarhead1',title:'青铜',hide:true},
						{field:'ItemWarhead2',title:'白银',hide:true},
						{field:'ItemWarhead3',title:'黄金',hide:true},
						{field:'ItemWarhead4',title:'紫金',hide:true},
						{field:'IsBusinessman',title:'玩家/会长',templet:'#IsBusinessman',event:'setSign'},
						{field:'Currency',title:'携带金币',sort:true},
						{field:'BankCurrency',title:'金库金币',sort:true},
						{field:'StrongDifficultyLevel',title:'强控个人等级难度',templet:'#StrongDifficultyLevel',event:'StrongDifficultyLevel'},
						{field:'StrongDifficultyWinLost',title:'强控剩余输赢分数',templet:'#StrongDifficultyWinLost'},
						{field:'PersonalDifficultyLevel',title:'自控个人等级难度',sort:true,templet:'#PersonalDifficultyLevel'},
						{field:'PersonalCurrentPrizePool',title:'当前奖池'},
						{field:'PersonalMaxPrizePool',title:'奖池最大值',event:'setPool',style:"color:red",templet:'#PersonalMaxPrizePool'},
						{field:'PersonalRecoverPoint',title:'回血点数',hide:true},
						{field:'PersonalInRecoverState',title:'回血状态',templet:'#PersonalInRecoverState',style:"color:red"},
						{field: 'TotalCurrencyLost',title: '总输',sort: true,hide:true}, 
						{field: 'TotalCurrencyWin',title: '总赢',sort: true,hide:true},
						{field: 'RealGain',title: '总输赢',sort: true,templet:'#RealGain'},
						{field:'TotalRecharge',title:'充值',sort:true,templet:'#TotalRecharge'},
						{field:'RegisterTime',title:'注册时间',sort:true},
						{field:'LastLoginTime',title:'最后登陆时间'},
						{field:'RegisterIp',title:'注册IP',hide:true},
						{field:'LastLoginIp',title:'最后登录IP',hide:true},
						{field:'IsBlocked',title:'是否被锁定',hide:true},
						{field:'DifficultyLevel',title:'为玩家设置的难度级别',hide:true},
						{field:'DifficultyDestValue',title:'目标金币数量',hide:true},
						{field:'Phone',title:'绑定的手机号码',hide:true},
						{field:'BankPassword',title:'金库密码',hide:true},
						{fixed: 'right', width:80, title:'操作', toolbar:'#barDemo'}
						]],
						response:{
							statusCode : 200
						},
						parseData:function(res){
							console.log(res);
							return{
								"code":res.status,
								"msg":res.message,
								"count":res.count,
								"data":res.data
							};
						}
				});
                
				
				//表格重载
				var active = {
						reload:function(){
							table.reload('AllTable',{
								page:{
									cuur:1
								},
								where:{
									UserId:$('#playerID').val(),
									Businessman : $('#Businessman').val()
								}
							});
							return false;
						}
				};
				$('#SelectOrder').on('click',
				        function(){
				            var type = $(this).data('type');
				            active[type] ? active[type].call(this) : '';
				        });
				
				//按照当前的状态重载
				setInterval(function(){
	              	table.reload('AllTable', {});
	              },60000);
				
				//监听行工具事件
				  table.on('tool(PlayerShow)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
				  	if (history.state == null){
				  		pushHistory();
					}
				    var data = obj.data //获得当前行数据
				    ,layEvent = obj.event; //获得 lay-event 对应的值
					  var id = data.Id;
					  var Nickname = data.Nickname;
					  var RegisterIp = data.RegisterIp;
					  var LastLoginIp = data.LastLoginIp;
					  var Diamond = data.Diamond;
					  var ItemLock = data.ItemLock;
					  var ItemFreeze = data.ItemFreeze;
					  var ItemSummon = data.ItemSummon;
					  var ItemWild = data.ItemWild;
					  var ItemShadow = data.ItemShadow;
					  var Item10 = data.Item10;
					  var Item11 = data.Item11;
					  var Item12 = data.Item12;
					  var Item13 = data.Item13;
					  var Item14 = data.Item14;
					  var ItemMultipleHit = data.ItemMultipleHit;
					  var Integral = data.Integral;
					  var ItemTicket = data.ItemTicket;
					  var ItemWarhead1 = data.ItemWarhead1;
					  var ItemWarhead2 = data.ItemWarhead2;
					  var ItemWarhead3 = data.ItemWarhead3;
					  var ItemWarhead4 = data.ItemWarhead4;
					  var Phone = data.Phone;
					  var BankPassword = data.BankPassword;
					  var Currency = data.Currency;
					  var VipLevel = data.VipLevel;
					  var PersonalCurrentPrizePool = data.PersonalCurrentPrizePool;
					  var TotalRecharge = data.TotalRecharge / 100 +"."+ data.TotalRecharge % 100;
					  var RegisterTime = data.RegisterTime;
					  var LastLoginTime = data.LastLoginTime;
					  var PersonalInRecoverState = data.PersonalInRecoverState === true ? "回血" : "否";
					  var RealGain = data.TotalCurrencyWin - data.TotalCurrencyLost;
					  var BankCurrency = data.BankCurrency;
					  var PersonalMaxPrizePool = data.PersonalMaxPrizePool;

					  if(layEvent === 'detail'){
						var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['100%', '100%'],
							title: "查看玩家信息",
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/playRecords',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index);
								// 取到弹出层里的元素，并把编辑的内容放进去
								body.find(".UserId").html(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
								body.find(".zlastLoginIp").html(LastLoginIp);
								body.find("#nickname").html(Nickname);
								body.find("#RegisterIp").html(RegisterIp);
								
								body.find(".Diamond").html(Diamond);
								body.find("#ItemLock").html(ItemLock);
								body.find("#ItemFreeze").html(ItemFreeze);
								body.find("#ItemSummon").html(ItemSummon);
								body.find("#ItemWild").html(ItemWild);
								body.find("#ItemShadow").html(ItemShadow);
								body.find("#Item10").html(Item10);
								body.find("#Item11").html(Item11);
								body.find("#Item12").html(Item12);
								body.find("#Item13").html(Item13);
								body.find("#Item14").html(Item14);
								body.find("#ItemMultipleHit").html(ItemMultipleHit);
								body.find("#Integral").html(Integral);
								body.find("#ItemTicket").html(ItemTicket);
								body.find("#ItemWarhead1").html(ItemWarhead1);
								body.find("#ItemWarhead2").html(ItemWarhead2);
								body.find("#ItemWarhead3").html(ItemWarhead3);
								body.find("#ItemWarhead4").html(ItemWarhead4);
								body.find("#Phone").html(Phone);
								body.find("#BankPassword").html(BankPassword);
								body.find("#Currency").html(Currency);
								body.find("#VipLevel").html(VipLevel);
								body.find("#PersonalCurrentPrizePool").html(PersonalCurrentPrizePool);
								body.find("#TotalRecharge").html(TotalRecharge);
								body.find("#RegisterTime").html(RegisterTime);
								body.find("#LastLoginTime").html(LastLoginTime);
								body.find("#PersonalInRecoverState").html(PersonalInRecoverState);
								body.find("#RealGain").html(RealGain);
								body.find("#BankCurrency").html(BankCurrency);
								body.find("#PersonalMaxPrizePool").html(PersonalMaxPrizePool);

							},
							cancel:function(){
								window.history.back();
							}
						});
				    } else if(layEvent === 'adjust'){
						var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['1500px', '800px'],
							title: '调整玩家上下分',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/playAdjustment',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index); //绑定父子页面
								body.find(".zid").val(id);
								body.find(".zname").val(name);
								body.find("#Currency").val(currency);
							},
							cancel:function(){
								window.history.back();
							}
				      });
				    } else if(layEvent === 'edit'){
						var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['100%', '100%'],
							title: '锁定玩家',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/playBlock',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index);
								// 取到弹出层里的元素，并把编辑的内容放进去
								body.find(".zid").val(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
								body.find(".zname").val(name);
							},
							cancel:function(){
								window.history.back();
							}
						});
				    }else if(layEvent === 'edit2'){
						var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['100%', '100%'],
							title: '解锁玩家',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/playUnBlock',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index); //绑定父子页面
								// 取到弹出层里的元素，并把编辑的内容放进去
								body.find(".zid").val(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
								body.find(".zname").val(name);
								//parent.layer.close(index);//关闭子页面
							},
							cancel:function(){
								window.history.back();
							}
						});
				    }else if(layEvent === 'setSign'){
				    	var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['500px', '200px'],
							title: '设置会长',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/setBusinessman',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index); //绑定父子页面
								body.find(".zid").val(id); 
							},
							cancel:function(){
								window.history.back();
							}
						});
				    }else if(layEvent === 'VipExpChange'){
				    	var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['500px', '200px'],
							title: '充值Vip经验',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/setVip',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index); //绑定父子页面
								body.find(".zid").val(id); 
							},
							cancel:function(){
								window.history.back();
							}
						});
				    }else if(layEvent === 'setPool'){
				    	var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['500px', '200px'],
							title: '设置个人奖池',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/setPool',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index); //绑定父子页面
								body.find(".zid").val(id); 
							},
							cancel:function(){
								window.history.back();
							}
						});
				    }else if(layEvent === 'StrongDifficultyLevel'){
				    	var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['100%', '400px'],
							title: '强控个人难度',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/setPlayerDifficult',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index); //绑定父子页面
								body.find(".zid").val(id); 
							},
							cancel:function(){
								window.history.back();
							}
						});
				    }else if(layEvent === 'ViewUserMessage'){
						  var index = layer.open({
							  type: 2,
							  shadeClose: true,
							  shade: 0.5,
							  area: ['100%', '100%'],
							  title: "查看玩家信息",
							  skin: 'layer-ext-yourskin',
							  content: '<%=basePath%>pa/detail/playRecords',
							  success: function(layero, index) {
								  var body = layer.getChildFrame("body", index);
								  // 取到弹出层里的元素，并把编辑的内容放进去
								  body.find(".UserId").html(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
								  body.find(".zlastLoginIp").html(LastLoginIp);
								  body.find("#nickname").html(Nickname);
								  body.find("#RegisterIp").html(RegisterIp);

								  body.find(".Diamond").html(Diamond);
								  body.find("#ItemLock").html(ItemLock);
								  body.find("#ItemFreeze").html(ItemFreeze);
								  body.find("#ItemSummon").html(ItemSummon);
								  body.find("#ItemWild").html(ItemWild);
								  body.find("#ItemShadow").html(ItemShadow);
								  body.find("#Item10").html(Item10);
								  body.find("#Item11").html(Item11);
								  body.find("#Item12").html(Item12);
								  body.find("#Item13").html(Item13);
								  body.find("#Item14").html(Item14);
								  body.find("#ItemMultipleHit").html(ItemMultipleHit);
								  body.find("#Integral").html(Integral);
								  body.find("#ItemTicket").html(ItemTicket);
								  body.find("#ItemWarhead1").html(ItemWarhead1);
								  body.find("#ItemWarhead2").html(ItemWarhead2);
								  body.find("#ItemWarhead3").html(ItemWarhead3);
								  body.find("#ItemWarhead4").html(ItemWarhead4);
								  body.find("#Phone").html(Phone);
								  body.find("#BankPassword").html(BankPassword);
								  body.find("#Currency").html(Currency);
								  body.find("#VipLevel").html(VipLevel);
								  body.find("#PersonalCurrentPrizePool").html(PersonalCurrentPrizePool);
								  body.find("#TotalRecharge").html(TotalRecharge);
								  body.find("#RegisterTime").html(RegisterTime);
								  body.find("#LastLoginTime").html(LastLoginTime);
								  body.find("#PersonalInRecoverState").html(PersonalInRecoverState);
								  body.find("#RealGain").html(RealGain);
								  body.find("#BankCurrency").html(BankCurrency);
								  body.find("#PersonalMaxPrizePool").html(PersonalMaxPrizePool);
							  },
							  cancel:function(){
								  window.history.back();
							  }
						  });
					  }
				  });
				
				
				//排序
				table.on('sort(PlayerShow)',function(obj){
					table.reload('AllTable',{
						initSort:obj //记录初始排序，如果不设的话，将无法标记表头的 排序状态 
						,where:{
							field:obj.field    //排序字段
							,order:obj.type    //排序方式
						}
					});
				});
			});
		</script>
	</body>
</html>
